﻿using JT808Protocol.Abstracts;
using System;
using System.Collections.Generic;
using System.Reflection;

namespace JT808Protocol.Handlers
{
    public class JT808HandlerProvider
    {
        public static IEnumerable<MsgHandlerBase> GetHandlers()
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            var types = assembly.GetTypes();
            foreach (var type in types)
            {
                if (type.IsAssignableTo(typeof(MsgHandlerBase)) && type.Name != "DefaultHandler")
                {
                    object handlerObj = Activator.CreateInstance(type);
                    yield return (MsgHandlerBase)handlerObj;
                }
            }
        }
    }
}